package com.usian.service.impl;

import com.usian.mapper.PhoneMapper;
import com.usian.mapper.StudentMapper;
import com.usian.pojo.Phone;
import com.usian.pojo.Stundet;
import com.usian.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper userMapper;
    @Autowired
    private PhoneMapper phoneMapper;

    @Override
    public void addUser(List<String[]> stundets) {
        for (String[] stundet : stundets) {
            Stundet stundet1 = new Stundet();
            if(stundet.length>2){
                stundet1.setName(stundet[1]);
                stundet1.setSex(stundet[2]);
                stundet1.setAge(stundet[3]);
                userMapper.addUser(stundet1);
            }else{
                Phone phone = new Phone();
                phone.setDname(stundet[1]);
                phoneMapper.insert(phone);
            }

        }
    }

}
